import React, {useEffect, useRef, useState} from 'react';

const Index = props => {
    const [state, setState] = useState(["aa", "bb", "cc"])
    const myRef = useRef();//等价于createRef()
    return (
        <div>
            <input ref={myRef} onChange={() => {
                console.log(myRef.current.value)
                let a=[...state,myRef.current.value]
                setState(a)
            }}/>
            {
                state.map((item,index)=>{
                    return<div key={index}>{item}</div>
                })
            }
        </div>
    );
};

Index.propTypes = {};

export default Index;
